{include file="public/head" /}

<!--支付第一步-->
<div class="firstly">
    <div class="bindmobile-wrap">
        采用<span style="color:red">微信支付</span>，购买成功后，团购券将发到您的注册邮箱：<span class="mobile">{$user->email}</span><a
            class="link"></a>
    </div>

    <table class="table table-goods" cellpadding="0" cellspacing="0">
        <tbody>
        <tr>
            <th class="first">商品</th>
            <th width="120">单价</th>
            <th width="190">数量</th>
            <th width="140">优惠</th>
            <th width="140" class="last">小计</th>
        </tr>
        <tr class="j-row">
            <td class="vtop">
                <div class="title-area" title="{$deal->name}">
                    <div class="img-wrap">
                        <a href="" target="_blank"><img src="{$deal->image}"
                                                        width="130" height="79"></a>
                    </div>
                    <div class="title-wrap">
                        <div class="title">
                            <a href="" class="link">{$deal->name}</a>
                        </div>
                        <div class="attrs"></div>
                    </div>
                </div>
            </td>
            <td>￥<span class="font14">{$deal->current_price}</span></td>
            <td class="j-cell">
                <div class="buycount-ctrl">
                    <a class="j-ctrl ctrl minus disabled"><span class="horizontal"></span></a>
                    <input type="text" value="{$count}" maxlength="10">
                    <a class="ctrl j-ctrl plus"><span class="horizontal"></span><span class="vertical"></span></a>
                </div>
                <span class="err-wrap j-err-wrap"></span>
            </td>
            <td class="j-cellActivity">-￥<span></span><br></td>
            <td class="price font14">¥<span class="j-sumPrice">{$deal->current_price*$count}</span></td>
        </tr>
        </tbody>
    </table>


    <div class="final-price-area">应付总额：<span class="sum">￥<span
            class="price">{$deal->current_price*$count}</span></span></div>

    <div class="page-button-wrap">
        <a class="o2o_pay_alipay btn btn-primary">支付宝支付</a>
    </div>
    <div class="page-button-wrap">
        <a class="o2o_pay_weixin btn btn-primary">微信支付</a>
    </div>

    <div style="width: 100%;min-width: 1200px;height: 5px;background: #dbdbdb;margin: 50px 0 20px;"></div>
</div>

<!--支付第二步-->

<!--支付第三步-->
<div class="third">
    <div class="search">
        <img src="https://passport.baidu.com/export/reg/logo-nuomi.png"/>
        <div class="w-order-nav-new">
            <ul class="nav-wrap">
                <li>
                    <div class="no"><span>1</span></div>
                    <span class="text">确认订单</span>
                </li>
                <li class="to-line "></li>
                <li>
                    <div class="no"><span>2</span></div>
                    <span class="text">选择支付方式</span>
                </li>
                <li class="to-line "></li>
                <li class="current">
                    <div class="no"><span>3</span></div>
                    <span class="text">购买成功</span>
                </li>
            </ul>
        </div>
    </div>

    <div style="width: 980px;height: 300px;margin: 0 auto;text-align: center;line-height: 300px;font-size: 36px;">
        恭喜，购买成功！
    </div>
</div>

<div class="footer">
    <ul class="first">

    </ul>
    <ul class="second">

    </ul>
</div>

<script>
    //校验正整数
    function isNaN(number) {
        var reg = /^[1-9]\d*$/;
        return reg.test(number);
    }

    function inputChange(num) {
        if (!isNaN(num)) {
            $(".buycount-ctrl input").val("1");
        }
        else {
            $(".buycount-ctrl input").val(num);
            $(".j-sumPrice").text($("td .font14").text() * num - $(".j-cellActivity span").text());
            $(".sum .price").text($("td .font14").text() * num - $(".j-cellActivity span").text());
            if (num == 1) {
                $(".buycount-ctrl a").eq(0).addClass("disabled");
            }
            else {
                $(".buycount-ctrl a").eq(0).removeClass("disabled");
            }
        }
    }

    $(".buycount-ctrl input").keyup(function () {
        var num = $(".buycount-ctrl input").val();
        inputChange(num);
    });
    $(".minus").click(function () {
        var num = $(".buycount-ctrl input").val();
        num--;
        inputChange(num);
    });
    $(".plus").click(function () {
        var num = $(".buycount-ctrl input").val();
        num++;
        inputChange(num);
    });
    //进行支付宝支付
    $('.o2o_pay_alipay').click(function () {
        var count = $('.buycount-ctrl input').val();
        var price = $('.final-price-area .sum .price').text();
        url = "{:url('order/index',['id'=>$deal->id])}" + "&deal_count=" + count + "&total_price=" + price + "&pay=" + 1;
        window.open(url);
    })
    //进行微信支付
    $('.o2o_pay_weixin').click(function () {
        var count = $('.buycount-ctrl input').val();
        var price = $('.final-price-area .sum .price').text();
        url = "{:url('order/index',['id'=>$deal->id])}" + "&deal_count=" + count + "&total_price=" + price + "&pay=" + 2;
        window.open(url);
    })
</script>
</body>
</html>